var news_list = document.querySelector(".news-list");

var requestOptions = {
  method: "GET",
  redirect: "follow",
};

fetch(`${apirUrl}/api/getrecommendnews?pageViews=1&limit=15`, requestOptions)
  .then((response) => response.json())
  .then((result) => {
    console.log(result.news);

    //遍历数据
    for (let i = 0; i < result.news.length; i++) {
      var index_recomm_list = `
      <li class="news-list-item clearfix">
      <div class="news-list-img"><a href="${serverUrl}/view.html?newsid=${result.news[i].newsid}"><img src="${apirUrl}${result.news[i].imgsrc}"></a></div>
      <div class="news-list-title">
          <div class="title"><a href="${serverUrl}/view.html?newsid=${result.news[i].newsid}">${result.news[i].title}</a></div>
          <div class="author_title">
              <span class="time_address">${result.news[i].date}&nbsp;&nbsp;&nbsp;${result.news[i].keyword}</span>
              <span class="author"><a href="#"><i class="bi bi-eye-fill">${result.news[i].pageViews}</i></a></span>
          </div>
      </div>
  </li>
          `;
      news_list.innerHTML += index_recomm_list;
    }
  })
  .catch((error) => console.log("error", error));
